package util.Date;

import java.util.Calendar;
import java.util.Date;

/**
 * @author: leiwenkang
 * @date: 2020/4/23
 * @time: 11:26
 */
public class DateUtil {
    public static void main(String[] args) {
        System.out.println(getDataStartTime(-3) / 1000);
    }

    /**
     * 获取距离今天的某天的0点时间戳
     *
     * @return
     */
    public static long getDataStartTime(int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) + day);
        return calendar.getTime().getTime();
    }
}
